<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<!--suppress HtmlRequiredTitleElement -->
<head>
    <th:block th:include="include :: header('编辑生成信息')"/>
    <style>
        .layui-form-label {
            width: 120px !important;
        }

        .layui-input-block {
            margin-left: 150px !important;
        }
    </style>
</head>
<body onscroll="layui.admin.hideFixedEl();" class="theme-himio">
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief" lay-filter="genTbEdit">
                <ul class="layui-tab-title">
                    <li class="layui-this">字段信息（实时保存）</li>
                    <li>表及其它配置信息</li>
                </ul>
                <div class="layui-tab-content">
                    <!--字段生成信息-->
                    <div class="layui-tab-item layui-show">
                        <table id="colInfoTable" lay-filter="colInfoTable"></table>
                    </div>
                    <!--其他生成信息-->
                    <div class="layui-tab-item">
                        <form id="otherGenInfo" lay-filter="otherGenInfoForm" class="layui-form layui-row"
                              th:object="${table}">
                            <input name="tableId" type="hidden" th:field="*{tableId}"/>
                            <input name="tableName" type="hidden" th:field="*{tableName}"/>
                            <input name="tableComment" type="hidden"
                                   th:value="${(table.tableComment eq null || table.tableComment eq '')?'-':table.tableComment}"/>
                            <input name="className" type="hidden" th:field="*{className}"/>
                            <div class="layui-row layui-col-space20">
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">作者:</label>
                                        <div class="layui-input-block">
                                            <input name="functionAuthor" placeholder="请输入作者" class="layui-input"
                                                   lay-verType="tips" lay-verify="required" required
                                                   th:field="*{functionAuthor}"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row layui-col-space20">
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">生成模板:</label>
                                        <div class="layui-input-block">
                                            <select name="tplCategory" lay-verType="tips" lay-verify="required"
                                                    required>
                                                <option value="crud" th:field="*{tplCategory}">简单二维表（增删改查，参考角色管理）</option>
                                                <option value="more" disabled>后续版本添加...</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">生成模块名: <i
                                                class="fa fa-question-circle-o"
                                                lay-tips="用于 url 路径、 template 模板路径、权限标识第一部分，如 system、business等"></i></label>
                                        <div class="layui-input-block">
                                            <input name="moduleName" placeholder="请输入生成模块名" class="layui-input"
                                                   th:field="*{moduleName}"
                                                   lay-verType="tips" lay-verify="required" required/>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">生成功能名: <i class="fa fa-question-circle-o"
                                                                                  lay-tips="用作类描述，例如 用户"></i></label>
                                        <div class="layui-input-block">
                                            <input name="functionName" placeholder="请输入生成功能名" th:field="*{functionName}"
                                                   required lay-verify="required" lay-verType="tips"
                                                   class="layui-input"/>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">生成包路径: <i
                                                class="fa fa-question-circle-o"
                                                lay-tips="生成在哪个java包下，例如<br/> com.himiotech.business.xxx"></i></label>
                                        <div class="layui-input-block">
                                            <input name="packageName" placeholder="请输入生成包路径" th:field="*{packageName}"
                                                   required lay-verify="required" lay-verType="tips"
                                                   class="layui-input"/>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">生成业务名: <i class="fa fa-question-circle-o"
                                                                                  lay-tips="用于java包名，体现业务的具体含义，例如 user"></i></label>
                                        <div class="layui-input-block">
                                            <input name="businessName" placeholder="请输入生成业务名" th:field="*{businessName}"
                                                   class="layui-input"/>
                                        </div>
                                    </div>
                                    <div class="layui-form-item">
                                        <label class="layui-form-label">上级菜单: <i class="fa fa-question-circle-o"
                                                                                 lay-tips="分配到指定菜单下，例如 系统管理。<br/>生成代码时，系统菜单将会新增此菜单"></i></label>
                                        <div class="layui-input-block">
                                            <div id="gen-menu-tree" class="xm-select-demo" style="width: 300px;"></div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-row layui-col-space20">
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">默认排序字段: </label>
                                        <div class="layui-input-block">
                                            <select name="searchParams[fieldName]" lay-verType="tips"
                                                    lay-verify="required" lay-search
                                                    required>
                                                <option value="">请选择</option>
                                                <option th:each="col:${table.columns}" th:value="${col.javaField}"
                                                        th:selected="${table.fieldName eq col.javaField}"
                                                        th:text="${col.javaField}"></option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-md6">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label layui-form-required">默认排序方式:</label>
                                        <div class="layui-input-block">
                                            <select name="searchParams[sortType]" lay-verType="etips"
                                                    lay-verify="required"
                                                    required>
                                                <option value="">请选择</option>
                                                <option value="asc" th:selected="${'asc' eq table.sortType}">正序（ASC）</option>
                                                <option value="desc" th:selected="${'desc' eq table.sortType}">倒序（DESC）</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item" style="margin-left: 150px;">
                                <button class="layui-btn" lay-filter="saveGenConfig" lay-submit>保存</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!--插入-->
<script type="text/html" id="insertTpl">
    <input type="checkbox" name="isInsert" value="{{d.columnId}}" lay-skin="switch" lay-text="ON|OFF" lay-filter="isTpl"
           {{ d.isInsert=== '1' ? 'checked' : '' }}>
</script>
<!--编辑-->
<script type="text/html" id="editTpl">
    <input type="checkbox" name="isEdit" value="{{d.columnId}}" lay-skin="switch" lay-text="ON|OFF" lay-filter="isTpl"
           {{ d.isEdit=== '1' ? 'checked' : '' }}>
</script>
<!--列表-->
<script type="text/html" id="listTpl">
    <input type="checkbox" name="isList" value="{{d.columnId}}" lay-skin="switch" lay-text="ON|OFF" lay-filter="isTpl"
           {{ d.isList=== '1' ? 'checked' : '' }}>
</script>
<!--查询-->
<script type="text/html" id="queryTpl">
    <input type="checkbox" name="isQuery" value="{{d.columnId}}" lay-skin="switch" lay-text="ON|OFF" lay-filter="isTpl"
           {{ d.isQuery=== '1' ? 'checked' : '' }}>
</script>
<!--必填-->
<script type="text/html" id="requiredTpl">
    <input type="checkbox" name="isRequired" value="{{d.columnId}}" lay-skin="switch" lay-text="ON|OFF"
           lay-filter="isTpl" {{ d.isRequired=== '1' ? 'checked' : '' }}>
</script>

<!-- 字段描述编辑 -->
<script type="text/html" id="javaTypeTpl">
    <div class="ew-select-fixed">
        <select lay-filter="typeTpl" column-id="{{d.columnId}}" field-name="javaType">
            <option value="">请选择</option>
            <option value="Long" {{d.javaType=='Long'?'selected':''}}>Long</option>
            <option value="String" {{d.javaType=='String'?'selected':''}}>String</option>
            <option value="Integer" {{d.javaType=='Integer'?'selected':''}}>Integer</option>
            <option value="Double" {{d.javaType=='Double'?'selected':''}}>Double</option>
            <option value="BigDecimal" {{d.javaType=='BigDecimal'?'selected':''}}>BigDecimal</option>
            <option value="Date" {{d.javaType=='Date'?'selected':''}}>Date</option>
            <option value="LocalDateTime" {{d.javaType=='LocalDateTime'?'selected':''}}>LocalDateTime</option>
        </select>
    </div>
</script>

<!-- 查询方式 -->
<script type="text/html" id="queryTypeTpl">
    <div class="ew-select-fixed">
        <select lay-filter="typeTpl" column-id="{{d.columnId}}" field-name="queryType">
            <option value="">请选择</option>
            <option value="EQ" {{d.queryType=='EQ'?'selected':''}}>=</option>
            <option value="NE" {{d.queryType=='NE'?'selected':''}}>!=</option>
            <option value="GT" {{d.queryType=='GT'?'selected':''}}>&gt;</option>
            <option value="GE" {{d.queryType=='GE'?'selected':''}}>&gt;=</option>
            <option value="LT" {{d.queryType=='LT'?'selected':''}}>&lt;</option>
            <option value="LE" {{d.queryType=='LE'?'selected':''}}>&lt;=</option>
            <option value="LIKE" {{d.queryType=='LIKE'?'selected':''}}>LIKE</option>
            <option value="BETWEEN" {{d.queryType=='BETWEEN'?'selected':''}}>BETWEEN</option>
        </select>
    </div>
</script>

<!-- 查询方式 -->
<script type="text/html" id="htmlTypeTpl">
    <div class="ew-select-fixed">
        <select lay-filter="typeTpl" column-id="{{d.columnId}}" field-name="htmlType">
            <option value="">请选择</option>
            <option value="input" {{d.htmlType=='input'?'selected':''}}>文本框</option>
            <option value="textarea" {{d.htmlType=='textarea'?'selected':''}}>文本域</option>
            <option value="select" {{d.htmlType=='select'?'selected':''}}>下拉框</option>
            <option value="radio" {{d.htmlType=='radio'?'selected':''}}>单选框</option>
            <option value="checkbox" {{d.htmlType=='checkbox'?'selected':''}}>复选框</option>
            <option value="tinymce" {{d.htmlType=='tinymce'?'selected':''}}>富文本</option>
            <option value="datetime" {{d.htmlType=='datetime'?'selected':''}}>日期控件</option>
            <option value="upload" {{d.htmlType=='upload'?'selected':''}}>上传控件</option>
        </select>
    </div>
</script>

<!-- js部分 -->
<th:block th:include="include :: footer"/>
<script th:src="@{/static/assets/system/js/genTableEdit.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "tool/gen";
    var colTableData = [[${table}]];
    var allMenuTree = [[${allMenu}]];
    var dictTypes = [[${@dict.getTypeList()}]];
</script>
</body>
</html>